package com.library.service;

import org.apache.commons.codec.digest.DigestUtils;

import com.library.dao.UserDao;
import com.library.entity.User;

public class UserService {

	private UserDao dao = new UserDao();

	public User validUser(String name, String passwd) {
		User user = dao.findByName(name);
		if (user != null) {
			String pwd = DigestUtils.md5Hex(passwd);
			if (user.getPasswd().equals(pwd)) {
				return user;
			}
		}

		return null;
	}

	public static void main(String[] args) {
		String xx = DigestUtils.md5Hex("123456");
		System.out.println(xx);
	}
}
